# -*- coding: utf-8 -*-

# -------------------------------------------------------------------
# @Time    : 2024/6/26 15:35
# @Author  : lldhsds
# @File    : gunicorn_config.py.py
# @Description: 借助gunicorn实现多进程
# -------------------------------------------------------------------
import os

def get_cpu_count():
    try:
        with open('/sys/fs/cgroup/cpu/cpu.cfs_quota_us', 'r') as quota_file:
            quota = int(quota_file.read())
        with open('/sys/fs/cgroup/cpu/cpu.cfs_period_us', 'r') as period_file:
            period = int(period_file.read())
        if quota > 0 and period > 0:
            return quota // period
    except (FileNotFoundError, ValueError):
        pass
    return os.cpu_count()

workers = get_cpu_count()
threads = 1  # 每个工作进程的线程数
bind = '0.0.0.0:8000'

